package com.um.swing.dialog;

import com.um.swing.MainView;
import com.um.swing.common.util.MessageUtil;
import com.um.swing.common.util.WindowUtil;

import javax.swing.*;
import java.awt.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

/**
 * 名称：拼版设置窗口
 * 创建人：袁泉
 * 创建时间：2022年05月12日23:59:25
 */
public class JJoinSettingBckDialog extends JDialog {

    private static final long serialVersionUID = 2914192200129777056L;

    public static final Dimension W_SIZE = new Dimension(550, 215);

    private static JJoinSettingBckDialog __instance = null;

    public static JJoinSettingBckDialog getInstance() {
        if (__instance == null)
            __instance = new JJoinSettingBckDialog();
        return __instance;
    }

    private JJoinSettingBckDialog() {
        super(MainView.getInstance(),true);
        this.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
        WindowUtil.setIcon(this, null);
        setPreferredSize(W_SIZE);
        setSize(W_SIZE);
        setLocationRelativeTo(null);
        setVisible(false);
        setTitle("项目设置");
        initUI();
        bindEvent();
    }

    //初始化UI
    private void initUI() {
    }

    private void bindEvent() {
        this.addWindowListener(new WindowAdapter() {
            @Override
            public void windowClosing(WindowEvent e) {
                super.windowClosing(e);
                int btn = MessageUtil.confirm(__instance, "是否保存配置");
                if (btn == 0) {
                    //TODO:保存配置信息
                }
                __instance.setVisible(false);
            }
        });
    }
}
